<!doctype html>
<html>
{include file='index/header' title='音乐之家 － 留言板'}
{include file='index/read_header'}
{include file='index/effect_header'}
<script type="text/javascript">
  $(document).ready(function(){
    $("#jMenu").jMenu();
  })

</script>
<div class="container" style="margin-top:20px;">
  <div id="controller">
    {include file='index/contact'}
    <!--修改密码 弹窗 -->
    {include file='index/change_pwd'}
    {include file='index/personal'}
      <img src="__ROOT__/static/images/reback.png" @click="back" style="margin-top:-30px;cursor:pointer">
  </div>
  <div class="panel panel-default" style="font-size: 14px">
    <div class="panel-heading"  >
      <div style="font-size: 25px;font-family: 幼圆">标题：{$article->title}
      </div>
      </br>
      <div><strong>{$article->username} </strong> <img src="__ROOT__/static/images/level.png"  style="margin-top:-10px;">{$level_mes}级&nbsp;&nbsp;&nbsp;&nbsp;发表于&nbsp;&nbsp;{$article->create_time} &nbsp;&nbsp;&nbsp;访问次数：{$article->label_times}</div>
      {if condition="$level eq 0"}
      <div style="margin-top: 10px ;color: #1584b9">ip: {$article->req_ip}</div>{/if}

    </div>
    <div class="panel-body">
      {$article->content}
      <hr/>
      {volist name='comments' id='c'}
      <div class="well">
        {$c.content}
        <h6 style="color: #b97575 ;font-size: 14px" > <strong>{$c.username}</strong> 发表于 : {$c.create_time}</h6>
        {if condition="$level eq 0"}
        <div style="margin-top: 10px ;color: #1584b9">ip: {$c->req_ip}</div>{/if}
      </div>
      {/volist}
    </div>
  </div>

  {if condition="$article->op_auth eq 0"}
  <div class="panel panel-danger">
    <div class="panel-heading">发布评论</div>
    <div class="panel-body">
      <form method="post" action="__ROOT__/addcomment/{$article.id}/name/{$name}">
<!--        <div class="form-group">-->
<!--          <label for="exampleInputEmail1">姓名：</label>-->
<!--          <input type="text" class="form-control" name='username' placeholder="请输入你的昵称">-->
<!--        </div>-->
        <div class="form-group">
<!--          <label for="exampleInputPassword1">内容：</label>-->
          {include file='index/editor'}
        </div>

        <button type="submit" class="btn btn-primary"style="margin-left: 42.666667%">回复</button>
      </form>
    </div>
    {else /}
    <div class="panel panel-danger">
      <div class="panel-heading" style="text-align: center">此留言不可回复！</div>
  </div>
      {/if}

</div>
</div>
<script >

  var controller = new Vue({
    el : '#controller',
    data : {
      username: localStorage.mUser,
      changeP:false,
      abnormal_card:'',
      singular:{
        oldPWD:'',
        newPWD:'',
        newPWDr:'',
      },
      personal_button:false,
      personal_list:{},
      auth_level:true,
    },
    created: function() {
	  this.online();
	  this.getData();

    },
    // mounted() {
    //   // 关闭浏览器窗口的时候清空浏览器缓存在localStorage的数据
    //   window.onbeforeunload = function (e) {
    //     var storage = window.localStorage;
    //     storage.clear()
    //   }
    // },
    methods : {
		online:function() {
                var _self = this;
                libs.ajax('index/index/checkOnline', {

                },function (result) {
                    if(result.status==1)
                    {
                        alert('您已离线，请登录！');
                        localStorage.clear();
                        window.location.href = '/login'
                    }
                })
            },
        getData:function() {
          var _self = this;
          libs.ajax('index/index/checkUserInfo', {

          },function (result) {
            if(result.status==0)
            {
              if(result.auth_level == 0)
              {
                _self.auth_level = false
              }
            }
          })
        },
        dologout: function() {
          libs.ajax('index/login/DoLogout', {
          }, function(result) {
            if(result.status == 0)
            {
              localStorage.clear();
              alert(result.msg)
              window.location.href='/';
            }

          })
        },
        changePwd(){
          this.changeP=true;
          this.singular={}
        },
        send: function() {
          var _self = this;

          if(!_self.singular.oldPWD || !_self.singular.newPWD || !_self.singular.newPWDr){
            alert('表单不能为空')
            return;
          }

          if (_self.singular.newPWD.length < 6 || _self.singular.newPWD.length > 20) {
            alert("密码长度必须为6-20位，请重新输入！");
            return;
          }

          if (_self.singular.newPWD != _self.singular.newPWDr) {
            alert("新设置密码两次不一致，请重新输入！");
            return;
          }

          libs.ajax('index/regist/ChangePassword', {
            old_pwd : _self.singular.oldPWD,
            new_pwd : _self.singular.newPWD,
            new_pwd_a : _self.singular.newPWDr
          }, function(result) {
            alert(result.msg)
            if(result.status == 0){
              localStorage.clear()
              top.location.href = '/'
            }
          })
        },
        /*个人信息接口*/
        personal(){
          var _self = this;
          this.personal_button=true;
          libs.ajax('index/index/personal_info', {
          }, function(result) {
            _self.personal_list = result.data;
            console.log(_self.personal_list);
          })
        },
        back()
        {
            window.history.back();
        },
    }
  })
</script>

</html>
